package com.fdhwws.web.entity;

public class AjaxResult {
    public final static int SUCCESS = 200;
    public final static int ERROR = 500;

    public Integer code;

    public String msg;

    public Object data;

    public AjaxResult() {
    }

    public AjaxResult(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public AjaxResult(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    @Override
    public String toString() {
        return "AjaxResult{" +
                "code=" + code +
                ", msg='" + msg + '\'' +
                ", data=" + data +
                '}';
    }

    public static AjaxResult success(String msg, Object data) {
        return new AjaxResult(SUCCESS, msg, data);
    }

    public static AjaxResult error(String msg, Object data) {
        return new AjaxResult(ERROR, msg, data);
    }

    public boolean isSuccess() {
        return SUCCESS == code;
    }
}
